/*
* @Author: 窦子滨<zibin_5257@163.com>
* @Date: 2019-11-29 15:54
 */
package main

import (
	"bufio"
	"gitee.com/lanfengye2002/base/common"
	"io"
	"os"
	"strings"
)

//读取txt文件
func readTxt(fileName string) ([]string, error) {
	fi, err := os.Open(common.Path + "mi" + common.OSSEP + fileName)
	if err != nil {
		return nil, err
	}
	defer fi.Close()
	br := bufio.NewReader(fi)
	var temp = make([]string, 0, 500)
	for {
		a, _, c := br.ReadLine()
		if c == io.EOF {
			break
		}
		t:=strings.Trim(string(a)," ")
		t=strings.Trim(t,"\r")
		t=strings.Trim(t,"\n")
		if len(t)>0{
			temp = append(temp, t)
		}
	}
	return temp, nil
}

//读取初始化名单
func readUsersList() {
	var err error
	usersAllList,err=readTxt("mingdan.ini")
	if err!=nil{
		log.Error("加载全部抽奖名单错误：%s",err.Error())
		return
	}
	usersAllList=RemoveRepByLoop(usersAllList)
}

func readAlreadyList(){
	var err error
	alreadyList,err=readTxt("already.ini")
	if err!=nil{
		log.Error("加载已抽奖名单错误：%s",err.Error())
		return
	}
	alreadyList=RemoveRepByLoop(alreadyList)
}
